package com.itheima.d4_byte_stream;

import java.io.FileInputStream;
import java.io.InputStream;

public class FileInputStreamTest2 {
    public static void main(String[] args) throws Exception {
        InputStream is =new FileInputStream("Day17\\src\\itheima01.txt");

        /*byte[] buffer = new byte[3];
        int len =is.read(buffer);
        String s1 = new String(buffer);
        System.out.println(s1);
        System.out.println("每次读取的长度："+len);

        int len2 =is.read(buffer);

        String s2 = new String(buffer,0,len2);
        System.out.println(s2);
        System.out.println("每次读取的长度："+len2);

        is.close();*/

        //循环改造
        byte[] buffer = new byte[3];
        int len;
        while((len=is.read(buffer))!=-1){
            String s = new String(buffer,0,len);
            System.out.print(s);
        }

        //无法解决汉字乱码问题
        is.close();
    }
}
